<?php
function setCurrentCash($amount,$transaction_type,$update_by)
{
	$now = date("Y-m-d H:i:s");
	$sql = "select current_amount from current_cash order by cc_date desc limit 0,1";
	$res = mysql_query($sql);

	list($current_amount)=mysql_fetch_row($res);	
	if($transaction_type == 'in')
	{
		$current_amount = $amount + $current_amount;
	}
	else
	{
		$current_amount = $current_amount - $amount;
	}
 
	$sql = "insert into current_cash(transaction_amount,current_amount,transaction_type,update_by,cc_date) values('$amount','$current_amount','$transaction_type','$update_by','$now')";
	
	mysql_query($sql) or die(mysql_error() .$sql);
}

?>